<?php

/**
 * @Author: XHH
 * @Date:   2018-10-10 08:39:42
 * @Last Modified by:   VULCAN
 * @Last Modified time: 2018-10-23 08:20:16
 */
require_once "dbconn.php";
// 包含dbconn.php这个文件
$id=$_GET['id'];
echo $id;
$sql = "SELECT
customers.CompanyName,
customers.ContactName,
employees.LastName,
employees.FirstName,
employees.EmployeeID,
`order details`.OrderID,
`order details`.ProductID,
`order details`.UnitPrice,
`order details`.Quantity,
`order details`.Discount,
orders.OrderDate,
orders.RequiredDate,
products.ProductName,
orders.EmployeeID,
orders.CustomerID,
orders.OrderID,
products.ProductID,
customers.CustomerID
FROM
(customers,
employees,
`order details`)
INNER JOIN orders ON orders.CustomerID = customers.CustomerID AND orders.EmployeeID = employees.EmployeeID AND `order details`.OrderID = orders.OrderID
INNER JOIN products ON `order details`.ProductID = products.ProductID
WHERE
orders.OrderID =".$id;
$orderDetails= mysqli_query($conn,$sql);
?>
<table>
	<tr>
		<th>订单ID</th>
		<th>商品名</th>
		<th>单价</th>
		<th>数量</th>
		<th>折扣</th>
		<th>下单日期</th>
		<th>收货日期</th>
		<th>顾客姓名</th>
		<th>顾客公司</th>
		<th>售货员姓名</th>
		<th>售货员工号</th>
	</tr>
	<?php foreach ($orderDetails as $order): ?>

		<br>
	<tr>
		
		<td><?php echo $order['OrderID']; ?></td>
		<td><?php echo $order['ProductName']; ?></td>
		<td><?php echo $order['UnitPrice']; ?></td>
		<td><?php echo $order['Quantity']; ?></td>
		<td><?php echo $order['Discount']; ?></td>
		<td><?php echo $order['OrderDate']; ?></td>
		<td><?php echo $order['RequiredDate']; ?></td>
		<td><?php echo $order['ContactName']; ?></td>
		<td><?php echo $order['CompanyName']; ?></td>
		<td><?php echo $order['LastName'].$order['FirstName']; ?></td>
		<td><?php echo $order['EmployeeID']; ?></td>
	</tr>
	<?php endforeach ?>

</table>